<?php
session_start();
$sjh = $_SESSION['usjh'];
//echo "$sjh";
$din = "mysql:host=127.0.0.1;dbname=zgr";
$name = "root";
$password = "root";
$pdo = new PDO($din,$name,$password);
$res = $pdo->query("select * from lx8_may")->fetchAll(PDO::FETCH_ASSOC);
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>
<body>
<center>
    <form action="do.show.php" method="post">
        <h2>欢迎手机号为<?php echo $sjh; ?>的用户</h2>
        收款人:<select name="psjh" id="psjh">
            <option value="0">请选择手机号</option>
            <?php foreach ($res as $v) {  ?>
            <?php if($sjh!=$v['sjh']) { ?>
            <option value="<?php echo $v['sjh']; ?>"><?php echo $v['sjh'];  ?></option>
            <?php  } ?>
            <?php  } ?>
        </select>
        <input type="hidden" id="puname">
        <br>
        转账金额(元):<input type="text" id="money" name="money">
        <br>
        <input type="submit" value="转账">
    </form>
</center>
</body>
</html>
<script src="jquery.js"></script>
<script>
    $(document).on('change','#psjh',function () {
        var v=$(this).val();
        $.ajax({
            type:'post',
            data:{'v':v},
            url:'show1.php',
            success:function (msg) {
                $('#puname').prop('type','text');
                $('#puname').attr('value',msg);
            }
        })
    })
    $(document).on('blur','#money',function () {
        var v=$(this).val();
        $.ajax({
            type:'post',
            data:{'v':v},
            url:'show2.php',
            success:function (msg) {
                if(msg=='no')
                {
                    alert('金额不足,不能转账');
                }
            }
        })
    })
</script>
